/**
 * @author zhangqiang
 * @date   17/7/20
 */
import React, {Component} from 'react'
import {connect} from 'react-redux'
import { bindActionCreators } from 'redux'
import {Toast} from 'antd-mobile'
import {Title} from '../../components/common'
import common from '../../utils/common'
import style from './index.scss'


class PassInformation extends Component {
	constructor(props) {
		super(props);
		this.state={}
		this.type=this.props.params.type
	}

	toUrl(url) {
		this.context.router.push(url);
	}

	componentDidMount() {
		common.setViewTitle('通行证信息');
	}

	render() {
  		let cacheRes = JSON.parse(sessionStorage.getItem('passCache'));//首页缓存  订单确认页缓存
		let fmtAll = 'yyyy-MM-dd';
		let birthday=common.format(cacheRes.birthday,fmtAll);
		let validateEnd=common.format(cacheRes.validateEnd,fmtAll);
		let createTime=common.format(cacheRes.createTime,fmtAll);

		return (
			<div className={style.passInformation}>
				<div>
					<Title text="申请人证件信息" inLine={false} bgColor='#f2f2f2'/>
					<div className={style.passBox+' '+'cf'}>
						<p className={style.msg}>
							<span>申&nbsp;&nbsp;请&nbsp;人:</span>
							<span>{cacheRes.passName}</span>
						</p>
						<p className={style.msg}>
							<span>通行证号:</span>
							{
								this.type=='enCode'?
									<span>{cacheRes.passCode.substr(0,3)+'****'+cacheRes.passCode.substr(cacheRes.passCode.length-2,cacheRes.passCode.length)}</span>:
									<span>{cacheRes.passCode}</span>
							}
						</p>
						<p className={style.msg}>
							<span>出生日期:</span>
							<span>{birthday}</span>
						</p>
						<p className={style.msg}>
							<span>有效期至:</span>
							<span>{validateEnd}</span>
						</p>
						{
							cacheRes.birthPlace&&cacheRes.type!=5?
								<p className={style.msg}>
									<span>户&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;籍:</span>
									<span className='text-overflow-one' style={{width: '5.3rem',textAlign: 'right'}}>{cacheRes.birthPlace.replace(null,'')}</span>
								</p>:''
						}

				</div>
			</div>

				{
					cacheRes.type==1?
					<div></div>:
					cacheRes.type==3?
					<div>
						<Title text="个人信息" inLine={false} bgColor='#f2f2f2'/>
						<div className={style.passBox+' '+'cf'}>
							<p className={style.msg}>
								<span>身份证号:</span>
								{
									this.type=='enCode'?
										<span>{cacheRes.idCardNo.substr(0,4)+'******'+cacheRes.idCardNo.substr(cacheRes.idCardNo.length-4,cacheRes.idCardNo.length)}</span>
										:	<span>{cacheRes.idCardNo}</span>
								}
							</p>
						</div>
						<Title text="单位组织信息" inLine={false} bgColor='#f2f2f2'/>
						<div className={style.passBox+' '+'cf'}>
							<p className={style.msg}>
								<span>组织机构代码 <br/>或社会信用代码:</span>
								<span className={style.location}>{cacheRes.orgNbr}</span>
							</p>
							<p className={style.msg}>
								<span>单位组织名称:</span>
								<span>{cacheRes.orgName}</span>
							</p>
							<p className={style.msg}>
								<span>单位组织所在地:</span>
								<span>{cacheRes.orgPlace.replace(null,'')}</span>
							</p>
						</div>
					</div>:
					cacheRes.type==4?
					<div>
						<Title text="申请人证件信息" inLine={false} bgColor='#f2f2f2'/>
						<div className={style.passBox+' '+'cf'}>

							<p className={style.msg}>
								<span>身份证号:</span>
								{
									this.type=='enCode'?
										<span>{cacheRes.idCardNo.substr(0,4)+'******'+cacheRes.idCardNo.substr(cacheRes.idCardNo.length-4,cacheRes.idCardNo.length)}</span>:
										<span>{cacheRes.idCardNo}</span>
								}
							</p>
							<p className={style.msg}>
								<span>配偶姓名:</span>
								<span>{cacheRes.spouseName}</span>
							</p>
						</div>
					</div>:
					cacheRes.type==5?
					<div>
						<Title text="个人信息" inLine={false} bgColor='#f2f2f2'/>
							<div className={style.passBox+' '+'cf'}>
								{
									cacheRes.birthPlace?
										<p className={style.msg}>
											<span>户&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;籍:</span>
											<span className='text-overflow-one' style={{width: '5.3rem',textAlign: 'right'}}>{cacheRes.birthPlace.replace(null,'')}</span>
										</p>:''
								}
								<p className={style.msg}>
									<span>身份证号:</span>
									{
										this.type=='enCode'?
											<span>{cacheRes.idCardNo.substr(0,4)+'******'+cacheRes.idCardNo.substr(cacheRes.idCardNo.length-4,cacheRes.idCardNo.length)}</span>:
											<span>{cacheRes.idCardNo}</span>
									}
								</p>
						</div>
					</div>:null
				}

				{/*签注信息start*/}

				{/*申请人信息end*/}

				{/*单位组织信息start*/}

				{/*单位组织信息end*/}

				{/*个人信息start*/}

				{/*申请人信息end*/}


				<div>
				<Title text="签注信息" inLine={false} bgColor='#f2f2f2'/>
				<div className={style.passBox+' '+'cf'}>
					<p className={style.msg}>
						<span>签注类别:</span>
						<span>{cacheRes.bizShortName}</span>
					</p>
					<p className={style.msg}>
						<span>签注发票:</span>
						<span>{cacheRes.needInvoice==0?'不需要':'需要'}</span>
					</p>
						<p className={style.msg}>
						<span>签注种类:</span>
					{
						cacheRes.items.reverse().map((e,i)=>
							<span key={i}>{e.category==1?'香港':e.category==2?'澳门':null}，
							{
								e.times == 1?'三月一次':e.times == 2?'三月二次': e.times == 3?'三月多次':
											e.times == 4?'一年一次': e.times == 5?'一年二次':e.times == 6?'一年多次':null
							}{i==1?';':''}</span>
						)
					}
					</p>
					</div>
				</div>
				<div style={{height:'.5rem'}}></div>
			</div>
				)
    }
}

//使用context
PassInformation.contextTypes = {
    router: React.PropTypes.object.isRequired
};

PassInformation.defaultProps = {

};


export default connect()(PassInformation);
